package client.communication.listeners;

import client.Client;
import message.Message;
import message.PingClientResponseMessage;
import message.PingRequestMessage;
import communication.MessageListener;
import communication.MessageReceivedEvent;

public class PingListener implements MessageListener
{
	private final Client client;
	
	public PingListener(Client client)
	{
		this.client = client;
	}
	
	@Override
	public void messageRecieved(MessageReceivedEvent e)
	{
		client.getCommunicator().sendMessage(new PingClientResponseMessage());
	}

	@Override
	public boolean acceptsMessage(Message message)
	{
		return message.getClass().equals(PingRequestMessage.class);
	}
}
